package com.ieasy.module.site.web.action;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ieasy.basic.model.DataGrid;
import com.ieasy.basic.model.Msg;
import com.ieasy.basic.util.cons.Const;
import com.ieasy.module.common.web.action.BaseController;
import com.ieasy.module.site.service.IDocService;
import com.ieasy.module.site.web.form.DocForm;

@Controller
@RequestMapping("/admin/site/doc")
public class DocAction extends BaseController {

	@Inject
	private IDocService docService ;
	
	@RequestMapping("/doc_main_UI.do")
	public String doc_main_UI() {
		return Const.SITE + "doc_main_UI" ;
	}
	
	@RequestMapping("/doc_form_UI.do")
	public String doc_form_UI(DocForm form, Model model) throws Exception {
		if(null != form.getId() && !"".equals(form.getId())) {
			model.addAttribute("id", form.getId()) ;
		}
		if(null != form.getPid() && !"".equals(form.getPid())) {
			model.addAttribute("pid", form.getPid()) ;
		}
		return Const.SITE + "doc_form_UI" ;
	}
	
	@RequestMapping("/add.do")
	@ResponseBody
	public Msg add(DocForm form) throws Exception {
		return this.docService.add(form) ;
	}
	
	@RequestMapping("/delete.do")
	@ResponseBody
	public Msg delete(DocForm form) throws Exception {
		return this.docService.delete(form) ;
	}
	
	@RequestMapping("/update.do")
	@ResponseBody
	public Msg update(DocForm form) throws Exception {
		return this.docService.update(form) ;
	}
	
	@RequestMapping("/get.do")
	@ResponseBody
	public DocForm get(DocForm form) throws Exception {
		return this.docService.get(form) ;
	}
	
	@RequestMapping("/datagrid.do")
	@ResponseBody
	public DataGrid datagrid(DocForm form) throws Exception {
		return this.docService.datagrid(form) ;
	}
	
	@RequestMapping("/doNotNeedAuth_datagrid.do")
	@ResponseBody
	public DataGrid doNotNeedAuth_datagrid(DocForm form) throws Exception {
		return this.docService.datagrid(form) ;
	}
	
	@RequestMapping("/doNotNeedAuth_push.do")
	@ResponseBody
	public Msg doNotNeedAuth_push(@RequestParam String id) throws Exception {
		this.docService.push(id) ;
		return new Msg(true, "操作成功") ;
	}
	
	
}
